# -*- coding: UTF-8 -*-
import time
import os


def open_app(app_name, app_activity):
    msg = os.popen(
        "adb shell ps | findstr" + app_name).read().strip('\n')
    if msg:
        print("app 已经启动")
    else:
        os.system(
            'adb shell am start -n' + app_name + app_activity)
        print("app启动成功")


def operating():
    flag = 1
    while flag < 10000:
        time.sleep(2)
        os.system('adb shell input swipe   420 1035 420 186')  # 上滑
        time.sleep(15)  # 停留多久自行定义
        flag = flag + 1


if __name__ == '__main__':
    open_app("com.android.contacts", "/com.android.packageinstaller.PackageInstallerActivity")
    time.sleep(2)
    operating()
